home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / efun / map_array < prev    next >
Text File  |  2001-04-06  |  2KB  |  49 lines

  1. OBSOLETE
  2. SYNOPSIS
  3.         mixed *map_array(mixed *arr, string fun, string|object ob, mixed extra)
  4.         mixed *map_array(mixed *arr, closure cl, mixed extra)
  5.  
  6. DESCRIPTION
  7.         Returns an array holding the items of arr mapped through
  8.         ob->fun(element, extra) resp. the closure cl. The function fun
  9.         in ob is called for each element in arr with that element as
  10.         parameter. A second parameter extra is sent in each call if
  11.         given. ob can be an object or a string. Principal function:
  12.         
  13.         foreach (index) arr[index] = ob->fun(arr[index],extra);
  14.         
  15.         The value returned by ob->fun(array[index],extra) replaces the
  16.         existing element in the array. If arr is not an array, then 0
  17.         will be returned.
  18.  
  19.         The extra argument is optional and must not be a protected reference
  20.         like &(i[0]). If <ob> is omitted, or neither a string nor an object,
  21.         it defaults to this_object().
  22.  
  23.  
  24. EXAMPLE
  25.         string ask_for_uid(object obj) {
  26.            return getuid(obj);
  27.         }
  28.         
  29.         void func() {
  30.            string *names;
  31.            names = map_array(users(), "ask_for_uid", this_object());
  32.            /* equivalent but a bit smaller and faster is the following */
  33.            names = map_array(users(), #'getuid );
  34.            ...
  35.         }
  36.         
  37.         This will create an array holding all uids of the current
  38.         users.
  39.  
  40. HISTORY
  41.         Since LDMud 3.2.6 obsoleted by map().
  42.         Since LDMud 3.2.9, not available if driver is compiled without
  43.           USE_DEPRECATED.
  44.  
  45. SEE ALSO
  46.         filter(E), filter_objects(E), assoc(E),
  47.         intersect_alist(E), insert_alist(E), map(E), map_objects(E),
  48.         member(E), order_alist(E), sort_array(E), unique_array(E)
  49.